"""
本章节讲解的是路由参数的讲解
"""
from flask import Blueprint, request

route_param_blue = Blueprint("route-param", __name__, url_prefix="/route-param")


# string类型的路径匹配 username:是传入的参数 string是参数的类型
@route_param_blue.route("/get-string/<string:username>/")
def get_string(username):
    print(type(username))
    return username


# int类型的参数: 接收int类型的参数
@route_param_blue.route("/get-int/<int:age>/")
def get_int(age):
    print(type(age))
    return str(age)


# fload类型的传参
@route_param_blue.route("/get-float/<float:money>/")
def get_float(money):
    print(type(money))
    return str(money)


# path:支持/的字符串
@route_param_blue.route("/get-path/<path:name>/")
def get_path(name):
    print(type(name))
    return str(name)


# 获取uuid
@route_param_blue.route("/get-uuid/")
def get_uuid():
    import uuid
    return str(uuid.uuid4())


@route_param_blue.route("/get-uuid/<uuid:id>/")
def get_id(id):
    print(type(id))
    return str(id)


# any参数类型的传递
@route_param_blue.route("/get-any/<any(apple,orange,banana):fruit>/")
def get_any(fruit):
    print(type(fruit))
    return fruit


print("-----------请求方式的讲解-------")


# POST方式请求
@route_param_blue.route("/post-method", methods=["POST"])
def post_method():
    data = request.get_json()  # 获取json对象
    print(data)
    print(type(data))
    return data


"""
请求参数
{
    "request_id":"900000000656777",
    "session_id":"LSJWR4096PS083548169511788336",
    "timestamp":"1695117927776",
    "user_id":"9000000006567824",
    "prompt":"帮我写一篇1000的作文 题目是 我的祖国",
    "model":"chatglm_66b_test01",
    "params":{"temperature":0.9},
    "context":{
        "lat":31.183197,
        "lon":121.605395
    },
    "character":"车载助手",
    "knowlege_base":true,
	 "vin":"LSJA24396BS11003",
	  "sid":"123456 "
 }
"""
